import request from '@/utils/request'

/**
 * 获取告警列表
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export function getAlerts(params) {
  return request({
    url: '/api/alerts',
    method: 'get',
    params
  })
}

/**
 * 获取单个告警
 * @param {String} alertId 告警ID
 * @returns {Promise}
 */
export function getAlert(alertId) {
  return request({
    url: `/api/alerts/${alertId}`,
    method: 'get'
  })
}

/**
 * 解决告警
 * @param {String} alertId 告警ID
 * @param {Object} data 解决数据
 * @returns {Promise}
 */
export function resolveAlert(alertId, data) {
  return request({
    url: `/api/alerts/${alertId}/resolve`,
    method: 'post',
    data
  })
}

/**
 * 删除告警
 * @param {String} alertId 告警ID
 * @returns {Promise}
 */
export function deleteAlert(alertId) {
  return request({
    url: `/api/alerts/${alertId}`,
    method: 'delete'
  })
}

/**
 * 检查任务告警
 * @param {String} taskId 任务ID
 * @returns {Promise}
 */
export function checkTaskAlerts(taskId) {
  return request({
    url: `/api/alerts/check/task/${taskId}`,
    method: 'get'
  })
}

/**
 * 检查系统告警
 * @returns {Promise}
 */
export function checkSystemAlerts() {
  return request({
    url: '/api/alerts/check/system',
    method: 'get'
  })
}